<template>
  <el-aside width="250px" class="sidebar">
    <div class="logo">
      <h2>南通大学</h2>
      <p>管理后台</p>
    </div>
    
    <el-menu
      :default-active="activeTab"
      class="sidebar-menu"
      @select="handleMenuSelect"
    >
      <el-menu-item index="hierarchy">
        <el-icon><Operation /></el-icon>
        <span>层级管理</span>
      </el-menu-item>
      <el-menu-item index="pages">
        <el-icon><Document /></el-icon>
        <span>页面管理</span>
      </el-menu-item>
      <el-menu-item index="categories">
        <el-icon><Folder /></el-icon>
        <span>分类管理</span>
      </el-menu-item>
      <el-menu-item index="items">
        <el-icon><List /></el-icon>
        <span>项目管理</span>
      </el-menu-item>
    </el-menu>
  </el-aside>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue'
import {
  Document,
  Folder,
  List,
  Operation
} from '@element-plus/icons-vue'

// Props
const props = defineProps({
  activeTab: {
    type: String,
    required: true
  }
})

// Events
const emit = defineEmits(['menu-select'])

// 菜单选择处理
const handleMenuSelect = (key) => {
  emit('menu-select', key)
}
</script>

<style scoped>
.sidebar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.logo {
  padding: 16px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.logo h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.logo p {
  margin: 4px 0 0 0;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.9;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sidebar-menu {
  border: none;
  background: transparent;
  padding: 0 12px;
}

.sidebar-menu .el-menu-item {
  color: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  margin: 0 0 6px 0;
  width: 100%;
  height: 56px;
  line-height: 56px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 16px;
  font-weight: 600;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-menu .el-menu-item:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-menu .el-menu-item.is-active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  font-weight: 700;
  transform: translateX(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.sidebar-menu .el-menu-item .el-icon {
  margin-right: 12px;
  font-size: 20px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.sidebar-menu .el-menu-item span {
  font-size: 16px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 菜单项动画效果 */
.sidebar-menu .el-menu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 0;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
  border-radius: 0 2px 2px 0;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-menu .el-menu-item.is-active::before {
  height: 32px;
}

.sidebar-menu .el-menu-item:hover::before {
  height: 24px;
}
</style>